package com.ss.SmartStock.pojo.enums;  
  
import java.util.Arrays;  
import java.util.List;  
import java.util.stream.Collectors;  
  
public enum OperationStatusEnum {

    ADD("新增", "0"),    
    APPROVAL_REQUESTED("发起审批", "1"),    
    APPROVAL_APPROVED("审批通过", "2"),    
    APPROVAL_REJECTED("审批驳回", "3"),    
    ONLINE("上线", "4"),    
    OFFLINE("下线", "5");    
  
    private final String description;  
    private final String value;  
  
    OperationStatusEnum(String description, String value) {  
        this.description = description;  
        this.value = value;  
    }  
  
    public String getDescription() {  
        return description;  
    }  
  
    public String getValue() {  
        return value;  
    }  
  
    /**  
     * 获取值列表  
     *  
     * @return  
     */  
    public static List<String> getValues() {  
        return Arrays.stream(OperationStatusEnum.values()).map(OperationStatusEnum::getValue).collect(Collectors.toList());  
    }  
  
    /**  
     * 根据 value 获取枚举  
     *  
     * @param value  
     * @return  
     */  
    public static OperationStatusEnum getEnumByValue(String value) {  
        for (OperationStatusEnum status : OperationStatusEnum.values()) {  
            if (status.value.equals(value)) {  
                return status;  
            }  
        }  
        throw new IllegalArgumentException("No enum constant " + OperationStatusEnum.class.getName() + "." + value);  
    }  
  
    // 如果需要，可以添加根据描述获取枚举的方法  
    public static OperationStatusEnum getEnumByDescription(String description) {  
        for (OperationStatusEnum status : OperationStatusEnum.values()) {  
            if (status.description.equals(description)) {  
                return status;  
            }  
        }  
        throw new IllegalArgumentException("No enum constant " + OperationStatusEnum.class.getName() + " with description " + description);  
    }  
}